<?php
// @formatter:off
/**
 * @file rss.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-03-31 09:33:18 +0000 (Sun, 31 Mar 2013) $
 *
 * $Id: rss.php 60 2013-03-31 09:33:18Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0/rss.php $
 */
// @formatter:on

define('__RSS__', true);

require_once dirname(__FILE__).'/config/config.php';

if(!defined("WC_NOT_INSTALLED")) {
	header("Content-type: text/xml");

	$timer = WCTimer::Instance();
	$timer->startGlobal();

	require_once "{$wcPaths['includes-directory']}/dynamic.conf.php";
	require_once "{$wcPaths["includes-directory"]}/WCRss.php";

	if($_SERVER["REQUEST_METHOD"] == "POST") {
		$wcPageCache->disabled();
	}

	$cacheId = "RSS";
	if($wcAction) {
		if(isset($wcRSSHandlers[$wcAction])) {
			$noCache = false;
			if($wcPageCache->get($cacheId) === false) {
				$wcRSS = new WCRss();
				if(is_readable($wcRSSHandlers[$wcAction])) {
					include $wcRSSHandlers[$wcAction];
				} else {
					$noCache = true;
				}

				$wcPageCache->append($cacheId, $wcRSS->xml());
				if(!$noCache) {
					$wcPageCache->save($cacheId);
				}
			}

			echo $wcPageCache->get($cacheId);
		}
	}

	$timer->saveGlobal($cacheId);
}
?>